﻿using Business;
using Entity;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace BookManageSys.User
{
    public partial class UserMain : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                BindData();
            }
        }

        private void BindData()
        {
            ProductsBusiness pb = new ProductsBusiness();
            DataTable dt = pb.GetAllData();
            DataList1.DataSource = dt;
            DataList1.DataBind();
        }

        protected void BtnSearch_Click(object sender, EventArgs e)
        {
            ProductsEntity pe = new ProductsEntity();
            pe.Productname = TxtSearch.Text;

            ProductsBusiness pb = new ProductsBusiness();
            DataTable dt = pb.SearchAllData(pe);
            DataList1.DataSource = dt;
            DataList1.DataBind();
        }

        protected void DataList1_ItemCommand(object source, DataListCommandEventArgs e)
        {
            if (e.CommandName == "详情")
            {
                Response.Redirect("BookDetail.aspx?productid=" + e.CommandArgument);
            }
        }
    }
}